﻿using gregn6Lib;
using NursingFormSystem.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NursingFormSystem.TemperatureRecord
{
    public partial class CommonPrint : Form
    {
        GridppReport Report = new GridppReport();
        DataTable Dt = new DataTable();
        string GrfName = string.Empty;
        /// <summary>
        /// 公共打印
        /// 将数据表直接打印到grf报表
        /// 数据表列名与grf字段名一致
        /// 说明:grf里有name字段 datable里必须有name字段
        /// 说明:datable里有name字段 grf可以没有name字段
        /// </summary>
        /// <param name="dt">DataTable 数据表</param>
        /// <param name="grfFullName">报表文件名.扩展名</param>
        public CommonPrint(DataTable dt, string grfFullName)
        {
            InitializeComponent();
            this.GrfName = grfFullName;
            this.Dt = dt;
            Report.LoadFromFile(System.Windows.Forms.Application.StartupPath + @"\GRFModel\Ydhl_GRF\" + GrfName);
            Report.ConnectionString = Utility.GetDatabaseConnectionString();
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecord);
            axGRPrintViewer1.Report = Report;
        }

        private void ReportFetchRecord()
        {
            Utility.FillRecordToReport(Report, Dt);
        }

        private void CommonPrint_Load(object sender, EventArgs e)
        {
            axGRPrintViewer1.Start();
        }
    }
}